package com.ljq.cksp.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

import java.util.Random;

/**
 * @Author:ljq
 * @Date:2020/4/7
 */
@Service
public class MailUtil {

    @Autowired
    JavaMailSender javaMailSender;

    public boolean sendMail(String email, String content) {
        //建立邮件消息
        SimpleMailMessage mainMessage = new SimpleMailMessage();
        //发送者
        mainMessage.setFrom("wy752318775@163.com");
        //接收者
        mainMessage.setTo(email);
        //发送的标题
        mainMessage.setSubject("flyway");
        //发送的内容
        Random random=new Random();
        String verifyCode=String.valueOf(random.nextInt(10000));
        mainMessage.setText(content);
        javaMailSender.send(mainMessage);
        return false;
    }
}
